<?php
include ('chek.php');
if($input->get('do')=='edit'){
    $data_set=$_POST;
    foreach ($data_set as $key=>$val){
        $sql="update setting set `val`='{$val}' WHERE `key`='{$key}'";
        $sql_result=$db->query($sql);
        if($sql_result){
            header('location:setting.php');
        }else{
            die('执行失败！');
        }
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>添加博客</title>
    <?php include (PATH.'/header.inc.php'); ?>
</head>
<body>
<?php include ('./nav.inc.php')?>
<div class="container">
    <div class="row">
        <h1>系统管理<small class="pull-right"><a class="btn btn-default" href="blog.php">返回</a></small></h1>
        <hr/>
        <form class="form-horizontal" action="setting.php?do=edit" method="post">
            <?php
            foreach ($setting as $key=>$val)
                :?>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label"><?php echo $key;?></label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="<?php echo $key;?>" value="<?php echo $val;?>">
                    </div>
                </div>
                <?php endforeach
            ;?>



            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-6">
                    <button type="submit" class="btn btn-default"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>
